import { request, config } from 'utils'

const { api } = config
const { customerIdentList, customerIdentAdd, customerIdentEdit, customerIdentDel } = api
const { accoutSignIdentList, accoutSignIdentAdd, accoutSignIdentEdit, accoutSignIdentDel } = api

function apiSelect (type) {
  let IdentApi = {}
  switch (type) {
    case 'customerIdent':
      IdentApi.listAPI = customerIdentList
      IdentApi.createAPI = customerIdentAdd
      IdentApi.updateAPI = customerIdentEdit
      IdentApi.delAPI = customerIdentDel
      break
    case 'signIdent':
      IdentApi.listAPI = accoutSignIdentList
      IdentApi.createAPI = accoutSignIdentAdd
      IdentApi.updateAPI = accoutSignIdentEdit
      IdentApi.delAPI = accoutSignIdentDel
      break
    default:
  }
  return IdentApi
}
export async function list (params) {
  const { listAPI } = apiSelect(params.type)
  return request({
    url: listAPI,
    method: 'put',
    data: params,
  })
}

export async function create (params) {
  const { createAPI } = apiSelect(params.type)
  return request({
    url: createAPI,
    method: 'post',
    data: params.data,
  })
}

export async function update (params) {
  const { updateAPI } = apiSelect(params.type)
  return request({
    url: updateAPI,
    method: 'put',
    data: params.data,
  })
}
export async function remove (params) {
  const { delAPI } = apiSelect(params.type)
  return request({
    url: delAPI,
    method: 'delete',
    data: params,
  })
}

